import { createRouter, createWebHashHistory } from 'vue-router'
export default createRouter({
  history: createWebHashHistory(),
  scrollBehavior () {
    // ...
    return {
      // vue2: x,y
      // vue3: top,left
      top: 0
    }
  },
  routes: [
    { path: '/login', component: () => import('@/views/login/index.vue') },
    {
      path: '/',
      // alias: '/home', // 别名
      redirect: '/home',
      //   redirect 重定向，与别名的区别，设置重定向后，只有重定向的路由路径可以访问，但是别名是两个都可以访问
      component: () => import('@/views/layout/index.vue'),
      children: [
        {
          path: '',
          component: () => import('@/views/home/index.vue')
        },
        {
          path: '/category/:id',
          component: () => import('@/views/category/index.vue')
        },
        {
          path: '/category/sub/:id',
          component: () => import('@/views/category/sub.vue')
        },
        {
          path: '/goods/:id',
          component: () => import('@/views/goods/index.vue')
        }
      ]
    }
  ]
})
